package org.zero.onlinesubject.handler;


import org.springframework.web.servlet.HandlerInterceptor;
import org.zero.onlinesubject.utils.UserContextHolder;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class AuthHandler implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        if(UserContextHolder.get()==null){
            response.setStatus(401);
            return false;
        }
        return true;
    }
}
